package com.kerbores.meeting.domain;

import java.util.Set;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Comment;
import org.nutz.dao.entity.annotation.ManyMany;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;

import com.kerbores.nutz.validation.annotation.Validations;

/**
 * @author Kerbores
 *
 *         Create At 2015年1月8日 下午3:29:02
 */
@Table("nutz_user")
public class User extends Entity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Validations(account = true, strLen = { 3, 6 }, errorMsg = "名称不合法,(字母开头，允许字母数字下划线,长度3到6位)")
	@Comment("用户名")
	@Column("name")
	private String name;
	@Comment("用户密码,md5")
	@Column("pwd")
	private String pwd;
	@Comment("qq号")
	@Column("qq")
	@Validations(qq = true, errorMsg = "QQ号码不正确")
	private String qq;
	@Comment("电子邮箱")
	@Column("email")
	@Validations(email = true, errorMsg = "邮箱地址不正确")
	private String email;
	@Comment("电话号码")
	@Column("phone")
	@Validations(mobile = true, errorMsg = "电话号码不正确")
	private String phone;
	@Comment("职位编号")
	@Column("pos_id")
	private long positionId;
	/**
	 * 用户职位
	 */
	@One(target = Position.class, field = "positionId")
	private Position position;
	/**
	 * 用户角色
	 */
	@ManyMany(target = Role.class, relation = "nutz_user_role", from = "user_id", to = "role_id")
	private Set<Role> roles;
	/**
	 * 用户权限
	 */
	@ManyMany(target = Permission.class, relation = "nutz_user_permission", from = "user_id", to = "permission_id")
	private Set<Permission> permissions;

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the permissions
	 */
	public Set<Permission> getPermissions() {
		return permissions;
	}

	/**
	 * @return the phone
	 */
	public String getPhone() {
		return phone;
	}

	/**
	 * @return the position
	 */
	public Position getPosition() {
		return position;
	}

	/**
	 * @return the positionId
	 */
	public long getPositionId() {
		return positionId;
	}

	/**
	 * @return the pwd
	 */
	public String getPwd() {
		return pwd;
	}

	/**
	 * @return the qq
	 */
	public String getQq() {
		return qq;
	}

	/**
	 * @return the roles
	 */
	public Set<Role> getRoles() {
		return roles;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param permissions
	 *            the permissions to set
	 */
	public void setPermissions(Set<Permission> permissions) {
		this.permissions = permissions;
	}

	/**
	 * @param phone
	 *            the phone to set
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}

	/**
	 * @param position
	 *            the position to set
	 */
	public void setPosition(Position position) {
		this.position = position;
	}

	/**
	 * @param positionId
	 *            the positionId to set
	 */
	public void setPositionId(long positionId) {
		this.positionId = positionId;
	}

	/**
	 * @param pwd
	 *            the pwd to set
	 */
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	/**
	 * @param qq
	 *            the qq to set
	 */
	public void setQq(String qq) {
		this.qq = qq;
	}

	/**
	 * @param roles
	 *            the roles to set
	 */
	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}
